package com.qingcheng.java.ai.langchain4j.controller;

import com.qingcheng.java.ai.langchain4j.assistant.XiaoheiAgent;
import com.qingcheng.java.ai.langchain4j.bean.ChatForm;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@Tag(name = "小黑")
@RestController
@RequestMapping("/xiaohei")
@RequiredArgsConstructor
public class XiaoheiController {

    private final XiaoheiAgent XiaoheiAgent;

    @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
    @Operation(summary = "对话")
    public Flux<String> chat(@RequestBody ChatForm chatForm) {
        return XiaoheiAgent.chat(chatForm.getMemoryId(), chatForm.getMessage());
    }
}
